home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / jpegagasrc / jpegaga / pattern.c < prev    next >
C/C++ Source or Header  |  1995-11-08  |  1KB  |  63 lines

  1. /* Fill the buffer with file names */
  2.  
  3. #include <dos/dosasl.h>
  4.  
  5. #define __NOLIBBASE__
  6. #include <proto/dos.h>
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. #define MAXFILES 500
  12.  
  13. extern char *PicArray[];
  14. extern int NumPictures;
  15. extern void FreeASL(void);
  16.  
  17.  
  18. void FillNameBuffer(char *pattern)
  19. {
  20.  int i;
  21.  LONG error;
  22.  struct AnchorPath *MyAnchorPath;
  23.  
  24.  MyAnchorPath = calloc(sizeof(struct AnchorPath)+256, 1);
  25.  
  26.  if(MyAnchorPath == NULL)
  27.  {
  28.    printf("Out of memory!\n");
  29.    FreeASL();
  30.    exit(10);
  31.  }
  32.  
  33.  MyAnchorPath->ap_Strlen = 254;
  34.  
  35.  error = MatchFirst(pattern, MyAnchorPath);
  36.  if(error) return;
  37.  
  38.  while(!error)
  39.  {
  40.    PicArray[NumPictures] = malloc(strlen((char *)&MyAnchorPath->ap_Buf)+1);
  41.    if(!PicArray[NumPictures])
  42.    {
  43.      printf("Out of memory!\n");
  44.      MatchEnd(MyAnchorPath);
  45.      FreeASL();
  46.      exit(10);
  47.    }
  48.    strcpy(PicArray[NumPictures], MyAnchorPath->ap_Buf);
  49.    /* puts(PicArray[NumPictures]); */
  50.    NumPictures++;
  51.    if(NumPictures == MAXFILES)
  52.    {
  53.      printf("Too many files!\n");
  54.      MatchEnd(MyAnchorPath);
  55.      return;
  56.    }
  57.    error = MatchNext(MyAnchorPath);
  58.  }
  59.  
  60.  MatchEnd(MyAnchorPath);
  61.  if(MyAnchorPath) free(MyAnchorPath);
  62. }
  63.